#ifndef _STEER_H_
#define _STEER_H_

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <strings.h>
#include <string.h>

#define BAUDRATE 115200
#define NBITS 8
#define STOPBITS 1

enum uart_port {
	COMPORT1 = 1,
	COMPORT2 = 2,
	COMPORTMAX,
};

enum check_event {
	ODD,
	EVEN,
	NONE,
	EVENT_MAX,
};

struct uart_desc {
	enum uart_port port;
	unsigned int baudrate;
	unsigned char nbits;
	unsigned char stopbits;
	enum check_event event;
};

enum steering_cmd {
	VERSION,
	SPEED0,
	SPEED7,
	DEGREE0,
	DEGREE90,
	DEGREE180,
	POS_READ,
	STAT_READ,
	BUT_READ,
	LED_ON,
	LED_OFF,
	STEERING_MAX
};

extern int uart_fd;
extern char buf_steer[8];

//配置串口
extern int uart_open (int com);
//设置串口的属性信息
extern int uart_setting (int fd, struct uart_desc uart);
//将命令写入到打开的串口设备的文件描述符中
extern int steering_ctrl (int fd, char *outdata, enum steering_cmd cmd);
//串口初始化
extern void uart_init (void);
//舵机0-90转动
extern void steer_auto (void);
//舵机旋转90度
extern void steer_90degree (void);
//舵机旋转0度
extern void steer_0degree (void);

#endif
